import com.niit.online.music.model.domain.Banner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ServiceTest {

    @Autowired
    private SongMapper songMapper;

    @Autowired
    private SongService songService;

    @Test
    public void songMapperTest(){
        QueryWrapper<Song> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("name","爱");
        List<Song> songs = songMapper.selectList(queryWrapper);
        for (Song s : songs) {
            System.out.println(s.toString());
        }
        Assert.assertThat(songs, Matchers.notNullValue());//assertThat断言后面介绍
    }

    @Test
    public void songServiceTest(){
        String name = "爱";
        R r = songService.songOfSingerName('%' + name + '%');
        List<Song> data = (List<Song>) r.getData();
        for (Song s: data ) {
            System.out.println(s.toString());
        }
        Assert.assertTrue("测试数据正确",r.getSuccess());
    }



}
